//
//  SIXAccountTool.m
//
//
//  Created by chenangel on 16/5/20.
//  Copyright © 2016年 chuhan. All rights reserved.
//
//

#import "SIXAccountTool.h"
#import "SIXAccount.h"

#define SIXAccountFileName [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"account.data"]

@implementation SIXAccountTool


static SIXAccount *_account;
+ (void)saveAccount:(SIXAccount *)account
{
    [NSKeyedArchiver archiveRootObject:account toFile:SIXAccountFileName];
}

+ (SIXAccount *)account
{
    if (_account == nil) {
        
        _account = [NSKeyedUnarchiver unarchiveObjectWithFile:SIXAccountFileName];

        if ([[NSDate date] compare:_account.expires_date] != NSOrderedAscending) { //
            return nil;
        }
        
    }
    
   
    return _account;
}

@end
